[Table of Contents] [docx version]

WordprocessingML Reference Material - Table of Contents

Table Styles

Table styles are style definitions which apply to the contents of zero or more tables within a document. This definition may imply that the style can only define table properties (properties which apply to the table and its constituent rows and cells), however a table style can also define paragraph properties (properties which apply to the positioning and appearance of paragraphs) as well as character properties (properties which apply to runs) for all of the paragraphs and runs within the specified table in the document.

Table styles can only be referenced by tables within a document, and they must be referenced by the tblStyle element (§2.4.59) within a table’s table properties.

As discussed above, table styles can specify all of the properties that can be applied to a table, as well as paragraph and character properties for the table’s contents. However, unlike other style definitions, table styles allow for the definition of conditional formats for different regions of the table.

These table conditional formats are applied to different regions of the table as follows:

All rows in the table can also have conditional formatting on an alternating row/column basis as well as follows:

When specified, these conditional formats shall be applied in the following order (therefore subsequent formats override properties on previous formats):

Whole table

Banded columns, even column banding

Banded rows, even row banding

First row, last row

First column, last column

Top left, top right, bottom left, bottom right

[Example: Consider a table style Test Table Style defined as follows:

All cells with 1pt table borders on all sides

0.1” cell margins on left and right of cells

0” cell margins on top and bottom of cells

As well as header row specific formatting of

Red shading

Bold text

<w:style w:type="table" w:styleId="TestTableStyle">
<w:name w:val="Test Table Style"/>
<w:basedOn w:val="TableNormal"/>
<w:priority w:val="99"/>
<w:rsid w:val="00340CC4"/>
<w:tblPr>
<w:tblBorders>
<w:top w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:bottom w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:insideH w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:insideV w:val="single" w:sz="4" w:space="0" w:color="auto"/>
</w:tblBorders>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
<w:tblStylePr w:type="firstRow">
<w:rPr>
<w:b/>
</w:rPr>
<w:tcPr>
<w:shd w:val="clear" w:color="auto" w:fill="ED1C24"/>
</w:tcPr>
</w:tblStylePr>
</w:style>

The tblPr element holds the formatting which is applied to the entire table, and the tblStylePr element with a type attribute value of firstRow holds the formatting for the first table row, specifically the bold run property and red cell shading. end example]

An individual instance of a table defines an association with a table style using the tblStyle element in the table’s properties (tblPr), as discussed above. However, individual tables can choose whether to apply the following aspects of the table’s conditional formats individually:

First row

Last row

First column

Last column

Row banding

Column banding

The use or omission conditional formats shall be specified using the tblLook element, which contains a bitmask representing which properties are applied and omitted.

[Example: Consider two tables using the table style Style2; one which specifies that it should only use the header row and footer row conditional formatting properties from the table style, and the other which specifies that it should use the header row, footer row, and banded row conditional formatting:

<w:tbl>

<w:tblPr>

<w:tblStyle w:val="Style2"/>

<w:tblW w:w="0" w:type="auto"/>

<w:tblLook w:val="0660"/>

</w:tblPr>

</w:tbl>

<w:tbl>

<w:tblPr>

<w:tblStyle w:val="Style2"/>

<w:tblW w:w="0" w:type="auto"/>

<w:tblLook w:val="0460"/>

</w:tblPr>

</w:tbl>

The tables each specify the appropriate set of conditional formats using the tblLook element, as seen by the identical table styles in the tblStyle element, and different tblLook values. end example]